using("Popup");

function Page(frame, grid, editPageUrl, addPageUrl, delMessage, helpPageUrl, printPageUrl, actionHidden, action){
    this.frame = frame;
    this.grid = grid;
    this.editPageUrl = editPageUrl;
    this.addPageUrl = addPageUrl;
    this.delMessage = delMessage;
    this.helpPageUrl = helpPageUrl;
    this.printPageUrl = printPageUrl; 
    this.actionHidden = actionHidden;
    
    EventHandler.windowEventHandler.registerListener("load", {"onload": function () {eval(this.action)}, "action":action});
}

Page.prototype.del = function () {
    if (confirm(this.delMessage)){
        if (this.frame!=null) this.frame.setOffStateDelayed();	
        return true;
    }
    return false;
}

Page.prototype.edit = function (source, params){
    if (typeof(params)=="string") params = Map.parse(params); 
    if (this.frame!=null) this.frame.load(this.editPageUrl, true, params);	
    if (this.grid!=null) this.grid.selectLine(source, params);
    return false;
}

Page.prototype.add = function (params) {
    if (typeof(params)=="string") params = Map.parse(params); 
    if (this.frame!=null) this.frame.load(this.addPageUrl, true, params);
    return false;	
}

Page.prototype.showHelp = function () {
				
    var popup = new Popup(this.helpPageUrl, 800, 600);
	//"toolbar=no,width=800,height=600,directories=no,status=no,scrollbars=yes,resizable=yes,border=0,menubar=no"
    popup.get();
    return false;
}

Page.prototype.printDocument = function (params) {
    if (typeof(params)=="string") params = Map.parse(params);
    var popup = new Popup(this.printPageUrl, 800, 600);
    popup.get(params);
    return false;
}

Page.prototype.postBack = function (eventTarget, eventArgument, doValidate, validationGroup){
    var params = {"eventTarget":eventTarget, "eventArgument":eventArgument, "validation":doValidate, "validationGroup":validationGroup, "trackFocus":false, "clientSubmit":true};
    WebForm_DoPostBackWithOptions(params);
    return false;
}

Page.prototype.setActionPending = function (funcCall){
	var hidden=document.createElement("input");
	hidden.type="hidden";
	hidden.name=this.actionHidden;
	hidden.value=funcCall;
    document.forms[0].appendChild(hidden);		
}